package com.cdu.eduPanda.project.utils;

import java.security.SecureRandom;

public class CodeGeneratorUtil {

    public static String generateCode(int length) {
        SecureRandom sr = new SecureRandom();
        byte[] bytes = new byte[length];
        sr.nextBytes(bytes);
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(String.format("%d", (b + 128) % 10));
        }
        return sb.toString();
    }
}
